package com.zm.zmgz.pojo;

import com.zm.zmgz.utils.DateUtils;

import java.util.Date;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: cjw
 * @Date: 2020/04/08/0:43
 * @Description:前端传入的日志搜索条件对象
 */
public class LogSearchCriteria {

    private String userName;
    private String type;
    private String tableName;
    private Long timeLimit;
    private Long timeLimit2;
    private Date timeLimitDate;
    private Date timeLimitDate2;
    private Integer page;
    private Integer limit;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Long getTimeLimit() {
        return timeLimit;
    }

    public void setTimeLimit(Long timeLimit) {
        this.timeLimit = timeLimit;
    }

    public Long getTimeLimit2() {
        return timeLimit2;
    }

    public void setTimeLimit2(Long timeLimit2) {
        this.timeLimit2 = timeLimit2;
    }

    public Date getTimeLimitDate() {
        return timeLimitDate;
    }

    public void setTimeLimitDate(Date timeLimitDate) {
        this.timeLimitDate = timeLimitDate;
    }

    public void setTimeLimitDatecjw() {
        this.timeLimitDate = new Date(getTimeLimit());
    }


    public Date getTimeLimitDate2() {
        return timeLimitDate2;
    }

    public void setTimeLimitDate2(Date timeLimitDate2) {
        this.timeLimitDate2 = timeLimitDate2;
    }

    public void setTimeLimitDate2cjw() {
        if(timeLimit == timeLimit2){
            timeLimit2 += 86400000;
        }
        this.timeLimitDate2 = new Date(getTimeLimit2());
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }

    @Override
    public String toString() {
        if(!Objects.isNull(getTimeLimitDate()) && !Objects.isNull(getTimeLimitDate2())) {
            return "LogSearchCriteria{" +
                    "userName='" + userName + '\'' +
                    ", type='" + type + '\'' +
                    ", tableName='" + tableName + '\'' +
                    ", timeLimit=" + timeLimit +
                    ", timeLimit2=" + timeLimit2 +
                    ", timeLimitDate=" + DateUtils.getDateString(getTimeLimitDate(),DateUtils.DATEFORMAT) +
                    ", timeLimitDate2=" + DateUtils.getDateString(getTimeLimitDate2(),DateUtils.DATEFORMAT) +
                    ", page=" + page +
                    ", limit=" + limit +
                    '}';
        } else {
            return "LogSearchCriteria{" +
                    "userName='" + userName + '\'' +
                    ", type='" + type + '\'' +
                    ", tableName='" + tableName + '\'' +
                    ", timeLimit=" + timeLimit +
                    ", timeLimit2=" + timeLimit2 +
                    ", timeLimitDate=" + timeLimitDate +
                    ", timeLimitDate2=" + timeLimitDate2 +
                    ", page=" + page +
                    ", limit=" + limit +
                    '}';
        }

    }
}
